﻿using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Bank;
using Bank.Account;

namespace BankUnitTest
{
    [TestClass]
    public class TestAccountCollection
    {
        [TestMethod]
        public void CreateAccountCollection()
        {
            AccountCollection col = new AccountCollection();
            Assert.IsNotNull(col);
        }

        [TestMethod]
        public void GetAccountByID()
        {
            decimal ballance = 1000;
            AccountCollection col = new AccountCollection();
            IAccount first = col.CreateCurrentAccount(1);
            IAccount second = col.CreateCurrentAccount(2, ballance);
            Assert.IsNotNull(col.GetAccountByID(first.Number, 1));
            Assert.IsNotNull(col.GetAccountByID(second.Number, 2));
            Assert.IsNull(col.GetAccountByID(first.Number, 2));
            Assert.IsNull(col.GetAccountByID(second.Number, 1));            
        }


        [TestMethod]
        public void CreateCurrentAccount()
        {
            decimal ballance = 1000;
            AccountCollection col = new AccountCollection();
            IAccount first = col.CreateCurrentAccount(1);
            IAccount second = col.CreateCurrentAccount(2, ballance);
            Assert.IsTrue(first is CurrentAccount);
            Assert.IsTrue(second is CurrentAccount);
            Assert.IsNotNull(col.GetAccountByID(first.Number, 1));
            Assert.IsNotNull(col.GetAccountByID(second.Number, 2));
            Assert.IsNull(col.GetAccountByID(first.Number, 2));
            Assert.IsNull(col.GetAccountByID(second.Number, 1));
            Assert.AreEqual(ballance, second.Ballance);
            Assert.AreEqual(0, first.Ballance);
        }

        [TestMethod]
        public void CreateDepositAccount()
        {
            decimal ballance = 1000;
            AccountCollection col = new AccountCollection();
            IAccount first = col.CreateDepositAccount(1);
            IAccount second = col.CreateDepositAccount(2, ballance);
            Assert.IsTrue(first is DepositAccount);
            Assert.IsTrue(second is DepositAccount);
            Assert.IsNotNull(col.GetAccountByID(first.Number, 1));
            Assert.IsNotNull(col.GetAccountByID(second.Number, 2));
            Assert.IsNull(col.GetAccountByID(first.Number, 2));
            Assert.IsNull(col.GetAccountByID(second.Number, 1));
            Assert.AreEqual(ballance, second.Ballance);
            Assert.AreEqual(0, first.Ballance);
        }
        [TestMethod]
        public void CreateForeignCurrencyAccount()
        {
            decimal ballance = 1000;
            AccountCollection col = new AccountCollection();
            IAccount first = col.CreateForeignCurrencyAccount(1, Currency.PLN);
            IAccount second = col.CreateForeignCurrencyAccount(2, ballance, Currency.EUR);
            Assert.IsTrue(first is ForeignCurrencyAccount);
            Assert.IsTrue(second is ForeignCurrencyAccount);
            Assert.IsNotNull(col.GetAccountByID(first.Number, 1));
            Assert.IsNotNull(col.GetAccountByID(second.Number, 2));
            Assert.IsNull(col.GetAccountByID(first.Number, 2));
            Assert.IsNull(col.GetAccountByID(second.Number, 1));
            Assert.AreEqual(ballance, second.Ballance);
            Assert.AreEqual(0, first.Ballance);
        }

        [TestMethod]
        public void CreateSavingsAccount()
        {
            decimal ballance = 1000;
            AccountCollection col = new AccountCollection();
            IAccount first = col.CreateSavingsAccount(1);
            IAccount second = col.CreateSavingsAccount(2, ballance);
            Assert.IsTrue(first is SavingsAccount);
            Assert.IsTrue(second is SavingsAccount);
            Assert.IsNotNull(col.GetAccountByID(first.Number, 1));
            Assert.IsNotNull(col.GetAccountByID(second.Number, 2));
            Assert.IsNull(col.GetAccountByID(first.Number, 2));
            Assert.IsNull(col.GetAccountByID(second.Number, 1));
            Assert.AreEqual(ballance, second.Ballance);
            Assert.AreEqual(0, first.Ballance);
        }

        [TestMethod]
        public void CreateSecondaryAccount()
        {
            decimal ballance = 1000;
            AccountCollection col = new AccountCollection();
            IAccount first = col.CreateSecondaryAccount(1);
            IAccount second = col.CreateSecondaryAccount(2, ballance);
            Assert.IsTrue(first is SecondaryAccount);
            Assert.IsTrue(second is SecondaryAccount);
            Assert.IsNotNull(col.GetAccountByID(first.Number, 1));
            Assert.IsNotNull(col.GetAccountByID(second.Number, 2));
            Assert.IsNull(col.GetAccountByID(first.Number, 2));
            Assert.IsNull(col.GetAccountByID(second.Number, 1));
            Assert.AreEqual(ballance, second.Ballance);
            Assert.AreEqual(0, first.Ballance);
        }
    }
}
